package com.quasar.hpatient.module.doctor_detail;

import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.quasar.hpatient.R;
import com.quasar.hpatient.api.HttpClient;
import com.quasar.hpatient.api.HttpParams;

import java.util.HashMap;

import io.reactivex.Observable;
import lib.quasar.base.frame.BasePresenter;
import lib.quasar.base.frame.OnModelAcceptChangeListener;
import lib.quasar.base.http.HttpResult;
import lib.quasar.context.BaseApp;
import lib.quasar.util.SpannableUtil;
import okhttp3.RequestBody;

/**
 * description: 我的医生 ==> 医生名片
 * created by kalu on 2018/3/27 14:47
 */
public class DoctorDetailPresenter implements BasePresenter {
    public String TAG = "DoctorDetailPresenter";

    void detailInfo(DoctorDetailView view, View root) {

        if (null == view || null == root) return;

        SpannableUtil.append(String.valueOf(120), BaseApp.getResource().getColor(R.color.color_bg_orange));
        SpannableUtil.newline();
        SpannableUtil.append("病人数量", BaseApp.getResource().getColor(R.color.color_bg_orange));
        final TextView count1 = root.findViewById(R.id.activity_doctor_detail_count_patient);
        view.setText(count1, SpannableUtil.build());

        SpannableUtil.append(String.valueOf(120), BaseApp.getResource().getColor(R.color.color_bg_blue));
        SpannableUtil.newline();
        SpannableUtil.append("浏览总量", BaseApp.getResource().getColor(R.color.color_bg_blue));
        final TextView count2 = root.findViewById(R.id.activity_doctor_detail_count_look);
        view.setText(count2, SpannableUtil.build());

        SpannableUtil.append(String.valueOf(95) + "%", BaseApp.getResource().getColor(R.color.color_bg_peach));
        SpannableUtil.newline();
        SpannableUtil.append("满意度", BaseApp.getResource().getColor(R.color.color_bg_peach));
        final TextView count3 = root.findViewById(R.id.activity_doctor_detail_count_feel);
        view.setText(count3, SpannableUtil.build());

        SpannableUtil.append("医生简介", BaseApp.getResource().getColor(R.color.color_black));
        SpannableUtil.newline();
        SpannableUtil.append("·医学博士，副主任医师，硕士生导师", BaseApp.getResource().getColor(R.color.color_font_gray60));
        SpannableUtil.newline();
        SpannableUtil.append("·在***某某杂志刊登论《器官移植能改善患者生活质量》，并获得***奖", BaseApp.getResource().getColor(R.color.color_font_gray60));
        SpannableUtil.newline();
        SpannableUtil.append("·处理罕见病例15起", BaseApp.getResource().getColor(R.color.color_font_gray60));
        SpannableUtil.newline();
        SpannableUtil.append("·擅长领域：泌尿科，肾移植", BaseApp.getResource().getColor(R.color.color_font_gray60));
        final TextView record = root.findViewById(R.id.activity_doctor_detail_record);
        view.setText(record, SpannableUtil.build());
    }

    void applyMessage(DoctorDetailView view, long doctorid) {

        final HashMap<String, Object> map = new HashMap<>();
        map.put(HttpParams.DOCTOR_ID, doctorid);

        map.put(HttpParams.RELATION_TYPE, String.valueOf(1));
        final RequestBody params = createParams(map, HttpParams.DATA_TYPE_16);

        final Observable<HttpResult<Object>> observable = HttpClient.getSingleHolder().getHttpService().applyFriend(params);
        Log.e(TAG, "-------------" + params.toString());
        request(observable, new OnModelAcceptChangeListener<Object>() {

            @Override
            public void modelFail() {
                view.toast("发送消息失败");
            }

            @Override
            public void modelSucc(Object result) {
                view.toast("发送消息成功");
            }
        });
    }

    @Override
    public void recycler() {
    }
}
